<template>
	<scroll-view class="page" scroll-y="true">
		<image class="iwidth" style="height:1500rpx;" :src="imgPath+'/static/big/bg1.jpg'" mode="scaleToFill"></image>
		<video object-fit="contain" class="dvideo" id="descVideo" :src="videoUrl" :poster="videoCoverUrl" controls @play="onPlay()" @pause="onPause" @ended="onPause"></video>
		<image class="iwidth btn1 breath" @click="lightBtn" src="/static/btn1.png" mode="widthFix"></image>
		<NickHead v-show="userBool" @success="finishBtn"></NickHead>
		<BgMusic ref="bgMusic"/>
		<ActivityEnd ref="activityEnd"/>
	</scroll-view>
</template>

<script>
	import user from '@/src/data/user'
	import http from '@/src/http'
	import platform from '@/src/platform'
	import NickHead from '@/components/nick-head.vue'
	export default {
		components:{
			NickHead
		},
		data() {
			return {
				userBool:false,
				videoUrl:'',
				videoCoverUrl:''
			}
		},
		onShow(){
            if(user.stage==3){
				this.$refs.activityEnd.show()
			}
		},
		async onLoad(options) {
			wx.hideHomeButton&&wx.hideHomeButton();
			let walkData = await platform.getWalkData();
			this.$nextTick(()=>{
				this.videoContext = uni.createVideoContext('descVideo');
				this.videoUrl = walkData.config.walkVideoUrl;
				this.videoCoverUrl = walkData.config.walkVideoCoverUrl;
				if(!user.avatar||!user.nickname){   //如果没有完成头像昵称验证
					this.userBool = true;
				}else{
					this.videoContext.play();
				}
			})
			this.shareTitle = '快来一起加入LightSpeed Walk吧！';
			this.shareImage = this.imgPath + '/static/big/activeA.jpg';
		},
		methods: {
			finishBtn(){
				this.userBool = false;
				this.videoContext.play();
			},
			lightBtn(){
				this.videoContext&&this.videoContext.pause();
				uni.navigateTo({
					url:'/pages/activeA/main/main'
				});

			},
			onPlay(){
				this.$refs.bgMusic.stop();
			},
			onPause(){
				this.$refs.bgMusic.play();
			}
		},

		onShareAppMessage() {
			http.writeLog({type:2});
			return {
				title:this.shareTitle,
				imageUrl:this.shareImage,
				path:'/pages/index?name=activeA'
			}
		},
		onShareTimeline() {
			http.writeLog({type:2});
			return {
				title:this.shareTitle,
				imageUrl:this.shareImage,
				path:'/pages/index?name=activeA'
			}
		}
	}
</script>

<style scoped>
.btn1{
	position: absolute;
	width: 58%;
	left:21%;
	top:76%;
}
.dvideo{
	position: absolute;
	width: 100%;
	left:0%;
	height:472rpx;
	top:36%;
}
</style>
